class InputMessageFileData {
  String? path;
  String? url;
  String? name;
  int? size;
  int type; // 1：图片，2：文件

  InputMessageFileData(
    this.type, {
    this.path,
    this.name,
    this.size,
        this.url,
  });

  Map<String, dynamic> toJson() {
    return {
      "path": path,
      "url": url,
      "name": name,
      "size": size,
      "type": type,
    };
  }

  factory InputMessageFileData.fromJson(Map<String, dynamic> json) {
    return InputMessageFileData(
      json["type"] ?? 0,
      path: json["path"],
      url: json["url"],
      name: json["name"],
      size: json["size"],
    );
  }
}

class InputMessageModel {
  List<InputMessageFileData> files;
  List<InputMessageFileData> imgs;
  String content;

  InputMessageModel({required this.files,required this.imgs,required this.content});

  Map<String, dynamic> toJson() {
    return {
      "files": files.map((e) => e.toJson()).toList(),
      "imgs": imgs.map((e) => e.toJson()).toList(),
      "content": content,
    };
  }

  factory InputMessageModel.fromJson(Map<String, dynamic> json) {
    List<InputMessageFileData> files = [];
    List<InputMessageFileData> imgs = [];
    String content = '';
    if (json['files'] != null) {
      for (var e in json['files']) {
        files.add(InputMessageFileData.fromJson(e));
      }
    }
    if (json['imgs'] != null) {
      for (var e in json['imgs']) {
        imgs.add(InputMessageFileData.fromJson(e));
      }
    }
    if (json['content'] != null) {
      content = json['content'];
    }

    return InputMessageModel(
      files: files,
      imgs: imgs,
      content: content,
    );
  }
}
